package com.weiiew.imageservice.controller;

import com.weiiew.imageservice.service.ImageServiceImpl;
import com.weiiew.common.utils.ApiResponse;
import com.weiiew.common.GatawayAccess.GatewayAccess;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description
 * @Author 魏锴
 * @Date 2024/7/22
 */
@RestController
@RequestMapping("/image")
@RequiredArgsConstructor
@GatewayAccess(GatewayAccess.GatewayType.MANAGER)
public class ImageController {
    private final ImageServiceImpl imageService;

    @PostMapping(value = "/save")
    public ApiResponse saveImage(@RequestHeader("my-version") String version, String type, String fileName, MultipartFile file) {
        System.out.println("type = " + type);
        System.out.println("fileName = " + fileName);
        return ApiResponse.response(imageService.saveImage(type, version, fileName, file), "保存图像");
    }
}
